<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>接受由 stream_socket_server 创建的套接字连接</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.stream-socket-accept" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_socket_accept</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">stream_socket_accept</span> &mdash; <span class="dc-title">接受由 <span class="function"><a href="stream_socket_server.html" class="function">stream_socket_server()</a></span> 创建的套接字连接</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.stream-socket-accept-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_socket_accept</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$server_socket</code></span>
   [, <span class="methodparam"><span class="type">float</span> <code class="parameter">$timeout</code><span class="initializer"> = ini_get(&quot;default_socket_timeout&quot;)</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$peername</code></span>
  ]] ) : <span class="type">resource</span></div>

  <p class="para rdfs-comment">
   接受由 <span class="function"><a href="stream_socket_server.html" class="function">stream_socket_server()</a></span> 创建的套接字连接。
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.stream-socket-accept-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">server_socket</code></dt>

     <dd>

      <p class="para">
       需要接受的服务器创建的套接字连接。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">timeout</code></dt>

     <dd>

      <p class="para">
       覆盖默认的套接字接受的超时时限。输入的时间需以秒为单位。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">peername</code></dt>

     <dd>

      <p class="para">
       如果包含该参数并且是可以从选中的传输数据中获取到，则将被设置给连接中的客户端主机的名称（地址）（怕出入很大，附带上原文：Will be set to the name (address) of the client which connected, if
       included and available from the selected transport.）

      </p>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <p class="para">
        也可以之后通过 <span class="function"><a href="stream_socket_get_name.html" class="function">stream_socket_get_name()</a></span> 来确定。
       </p>
      </p></blockquote>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-socket-accept-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回接受套接之后的资源流  或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.stream-socket-accept-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    该函数不能被用于 UDP 套接字。可以使用 <span class="function"><a href="stream_socket_recvfrom.html" class="function">stream_socket_recvfrom()</a></span> 和
    <span class="function"><a href="stream_socket_sendto.html" class="function">stream_socket_sendto()</a></span> 来取而代之。
   </p>
 </div>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.stream-socket-accept-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="stream_socket_server.html" class="function" rel="rdfs-seeAlso">stream_socket_server()</a> - Create an Internet or Unix domain server socket</span></li>
    <li class="member"><span class="function"><a href="stream_socket_get_name.html" class="function" rel="rdfs-seeAlso">stream_socket_get_name()</a> - 获取本地或者远程的套接字名称</span></li>
    <li class="member"><span class="function"><a href="stream_set_blocking.html" class="function" rel="rdfs-seeAlso">stream_set_blocking()</a> - 为资源流设置阻塞或者阻塞模式</span></li>
    <li class="member"><span class="function"><a href="stream_set_timeout.html" class="function" rel="rdfs-seeAlso">stream_set_timeout()</a> - Set timeout period on a stream</span></li>
    <li class="member"><span class="function"><a href="fgets.html" class="function" rel="rdfs-seeAlso">fgets()</a> - 从文件指针中读取一行</span></li>
    <li class="member"><span class="function"><a href="fgetss.html" class="function" rel="rdfs-seeAlso">fgetss()</a> - 从文件指针中读取一行并过滤掉 HTML 标记</span></li>
    <li class="member"><span class="function"><a href="fwrite.html" class="function" rel="rdfs-seeAlso">fwrite()</a> - 写入文件（可安全用于二进制文件）</span></li>
    <li class="member"><span class="function"><a href="fclose.html" class="function" rel="rdfs-seeAlso">fclose()</a> - 关闭一个已打开的文件指针</span></li>
    <li class="member"><span class="function"><a href="feof.html" class="function" rel="rdfs-seeAlso">feof()</a> - 测试文件指针是否到了文件结束的位置</span></li>
    <li class="member"><a href="ref.curl.html" class="xref">cURL 函数</a></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>